//package com.quartet.modules.equipment.controller;
//
//
//import cn.hutool.core.bean.BeanUtil;
//import com.alibaba.fastjson.JSON;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.extension.api.ApiController;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.quartet.api.ApiResult;
//import com.quartet.api.PageResult;
//import com.quartet.modules.equipment.dto.TPhotoRuleInfoAddRequestDto;
//import com.quartet.modules.equipment.dto.TPhotoRuleInfoQueryRequestDto;
//import com.quartet.modules.equipment.dto.TPhotoRuleInfoResponseDto;
//import com.quartet.modules.equipment.entity.TPhotoRuleInfo;
//import com.quartet.modules.equipment.service.TPhotoRuleInfoService;
//import com.quartet.utils.BeanTool;
//import com.quartet.utils.JsonTool;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.ObjectUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.web.bind.annotation.*;
//
//import javax.annotation.Resource;
//import java.util.List;
//import java.util.stream.Collectors;
//
///**
// * 拍照规则信息表(TPhotoRuleInfo)表控制层
// *
// * @author makejava
// * @since 2021-05-04 16:41:15
// */
//@RestController
//@RequestMapping("tPhotoRuleInfo")
//@Api(tags = "业务：拍照规则信息")
//@Slf4j
//public class TPhotoRuleInfoController  {
//    /**
//     * 服务对象
//     */
//    @Resource
//    private TPhotoRuleInfoService tPhotoRuleInfoService;
//
//    /**
//     * 分页查询所有数据
//     *
//     * @param tPhotoRuleInfoQueryRequestDto 查询实体
//     * @return 所有数据
//     */
//    @ApiOperation("分页查询所有拍照规则信息")
//    @PostMapping("/selectPhotoRulePage")
//    public ApiResult<PageResult<TPhotoRuleInfoResponseDto>> selectPhotoRulePage(@RequestBody TPhotoRuleInfoQueryRequestDto tPhotoRuleInfoQueryRequestDto) {
//        log.info("---------selectPhotoRulePage begin, tPhotoRuleInfoQueryRequestDto is {}----------", tPhotoRuleInfoQueryRequestDto);
//        IPage<TPhotoRuleInfo> page = new Page<>(tPhotoRuleInfoQueryRequestDto.getCurrent(), tPhotoRuleInfoQueryRequestDto.getLimit());
//        QueryWrapper<TPhotoRuleInfo> queryWrapper = new QueryWrapper<>();
//        if (!StringUtils.isNotBlank(tPhotoRuleInfoQueryRequestDto.getPhotoRuleName())) {
//            queryWrapper.lambda().like(TPhotoRuleInfo::getPhotoRuleName, tPhotoRuleInfoQueryRequestDto.getPhotoRuleName());
//        }
//        IPage<TPhotoRuleInfo> dbResult = tPhotoRuleInfoService.page(page, queryWrapper);
//        PageResult<TPhotoRuleInfoResponseDto> pageResult = new PageResult();
//        List<TPhotoRuleInfoResponseDto> tAlarmRuleInfoResponseDtoList = dbResult.getRecords().stream().map(tPhotoRuleInfo -> {
//            TPhotoRuleInfoResponseDto tPhotoRuleInfoResponseDto = BeanUtil.copyProperties(tPhotoRuleInfo, TPhotoRuleInfoResponseDto.class);
//            if (ObjectUtils.isNotEmpty(tPhotoRuleInfo.getPhotoChannel())) {
//                List<String> photoChannel = JSON.parseArray(tPhotoRuleInfo.getPhotoChannel().toString(), String.class);
//                tPhotoRuleInfoResponseDto.setPhotoChannel(photoChannel);
//            }
//            return tPhotoRuleInfoResponseDto;
//        }).collect(Collectors.toList());
//        pageResult.setTotal(dbResult.getTotal());
//        pageResult.setData(tAlarmRuleInfoResponseDtoList);
//        log.info("---------selectPhotoRulePage end, data is {}----------", pageResult);
//        return ApiResult.ok(pageResult);
//    }
//
//    /**
//     * 通过主键查询单条数据
//     *
//     * @param id 主键
//     * @return 单条数据
//     */
//    @ApiOperation("通过主键查询单条拍照规则信息")
//    @GetMapping("/selectPhotoRuleById")
//    public ApiResult<TPhotoRuleInfoResponseDto> selectPhotoRuleById(@RequestParam("id") String id) {
//        log.info("---------selectPhotoRuleById begin, id is {}----------", id);
//        TPhotoRuleInfo tPhotoRuleInfo = tPhotoRuleInfoService.getById(id);
//        TPhotoRuleInfoResponseDto tPhotoRuleInfoResponseDto = BeanUtil.copyProperties(tPhotoRuleInfo, TPhotoRuleInfoResponseDto.class);
//        if (ObjectUtils.isNotEmpty(tPhotoRuleInfo.getPhotoChannel())) {
//            List<String> array = JSON.parseArray(tPhotoRuleInfo.getPhotoChannel().toString(), String.class);
//            tPhotoRuleInfoResponseDto.setPhotoChannel(array);
//        }
//        return ApiResult.ok(tPhotoRuleInfoResponseDto);
//    }
//
//    /**
//     * 新增数据
//     *
//     * @param tPhotoRuleInfoAddRequestDto 实体对象
//     * @return 新增结果
//     */
//    @ApiOperation("新增拍照规则信息")
//    @PostMapping("/add")
//    public ApiResult addPhotoRule(@RequestBody TPhotoRuleInfoAddRequestDto tPhotoRuleInfoAddRequestDto) {
//        log.info("---------addPhotoRule begin, tPhotoRuleInfoAddRequestDto is {}----------", tPhotoRuleInfoAddRequestDto);
//        TPhotoRuleInfo tPhotoRuleInfo = BeanUtil.copyProperties(tPhotoRuleInfoAddRequestDto, TPhotoRuleInfo.class);
//        tPhotoRuleInfo.setPhotoChannel(JsonTool.beanToJson(tPhotoRuleInfoAddRequestDto.getPhotoChannel()));
//        return ApiResult.ok(this.tPhotoRuleInfoService.save(tPhotoRuleInfo));
//    }
//
//    /**
//     * 修改数据
//     *
//     * @param tPhotoRuleInfoAddRequestDto 实体对象
//     * @return 修改结果
//     */
//    @ApiOperation("修改拍照规则信息")
//    @PutMapping("update")
//    public ApiResult updatePhotoRule(@RequestBody TPhotoRuleInfoAddRequestDto tPhotoRuleInfoAddRequestDto) {
//        log.info("---------updatePhotoRule begin, tPhotoRuleInfoAddRequestDto is {}----------", tPhotoRuleInfoAddRequestDto);
//        TPhotoRuleInfo tPhotoRuleInfo = BeanUtil.copyProperties(tPhotoRuleInfoAddRequestDto, TPhotoRuleInfo.class);
//        tPhotoRuleInfo.setPhotoChannel(JsonTool.beanToJson(tPhotoRuleInfoAddRequestDto.getPhotoChannel()));
//        return ApiResult.ok(this.tPhotoRuleInfoService.updateById(tPhotoRuleInfo));
//    }
//
//    /**
//     * 删除数据
//     *
//     * @param id 主键
//     * @return 删除结果
//     */
//    @ApiOperation("删除拍照规则信息")
//    @DeleteMapping("/delete")
//    public ApiResult deletePhotoRule(@RequestParam("id") Integer id) {
//        return ApiResult.ok(this.tPhotoRuleInfoService.removeById(id));
//    }
//
//    /**
//     * 修改数据
//     *
//     * @param tPhotoRuleInfoAddRequestDtoList 实体对象
//     * @return 修改结果
//     */
//    @ApiOperation("批量修改拍照规则信息")
//    @PutMapping("batchUpdate")
//    public ApiResult batchUpdatePhotoRule(@RequestBody List<TPhotoRuleInfoAddRequestDto> tPhotoRuleInfoAddRequestDtoList) {
//        log.info("---------updatePhotoRule begin, tPhotoRuleInfoAddRequestDtoList is {}----------", tPhotoRuleInfoAddRequestDtoList);
//        List<TPhotoRuleInfo> tPhotoRuleInfoList = tPhotoRuleInfoAddRequestDtoList.stream().map(tPhotoRuleInfoAddRequestDto -> {
//            TPhotoRuleInfo tPhotoRuleInfo = BeanUtil.copyProperties(tPhotoRuleInfoAddRequestDto, TPhotoRuleInfo.class);
//            tPhotoRuleInfo.setPhotoChannel(JsonTool.beanToJson(tPhotoRuleInfoAddRequestDto.getPhotoChannel()));
//            return tPhotoRuleInfo;
//        }).collect(Collectors.toList());
//        return ApiResult.ok(this.tPhotoRuleInfoService.updateBatchById(tPhotoRuleInfoList));
//    }
//}
